﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;

namespace Aandelendelen.Ad
{
	public class AdvertiseCache
	{
		internal static AdvertiseOptionCollection GetAdvertiseOptions()
		{
			string cacheName = "advertiseoptions";

			AdvertiseOptionCollection advertiseOptions = AdvertiseCache.Cache[cacheName] as AdvertiseOptionCollection;

			if (advertiseOptions == null)
			{
				advertiseOptions = new AdvertiseOptionCollection();

				CacheDependency dependency = new CacheDependency(HttpContext.Current.Server.MapPath("/App_Data/AdvertiseOptions.xml"));

				AdvertiseCache.Cache.Insert(cacheName, advertiseOptions, dependency);
			}

			return advertiseOptions;
		}

		private static Cache Cache
		{
			get { return HttpContext.Current.Cache; }
		}

	}
}